// 1.引入request
import request from "@/utils/request"
// 引入约束
import type { categoryListModel, attrInfoListModel, attrInfoModel, categoryIds } from "./model/attr"
//2.枚举接口函数
enum Api{
  // 1.获取一级分类数据
  getAttrCategory1ListDataApi="/admin/product/getCategory1",
  // 2.获取二级分类数据
  getAttrCategory2ListDataApi="/admin/product/getCategory2",
  // 3.获取三级分类数据
  getAttrCategory3ListDataApi ="/admin/product/getCategory3",
  // 4.获取平台属性数据
  getAttrListDataApi = "/admin/product/attrInfoList",
  // 5.删除平台属性数据
  deleteAttrListApi = "/admin/product/deleteAttr",
  // 6.添加/修改平台属性数据
  saveAttrInfoApi ="/admin/product/saveAttrInfo"
  
}

// 3.发送请求获取一级分类数据
export const ReqGetAttrCategory1ListData = () => request.get<any, categoryListModel>(Api.getAttrCategory1ListDataApi)
// 4.发送请求获取二级分类数据
export const ReqGetAttrCategory2ListData = (category1Id: number) => request.get<any, categoryListModel>(`${Api.getAttrCategory2ListDataApi}/${category1Id}`)
// 5.发送请求获取三级分类数据
export const ReqGetAttrCategory3ListData = (category2Id: number) => request.get<any, categoryListModel>(`${Api.getAttrCategory3ListDataApi}/${category2Id}`)
// 6.发送请求获取 平台属性 数据
export const ReqGetAttrListData = ({ category1Id, category2Id, category3Id }: categoryIds) => request.get<any, attrInfoListModel>(`${Api.getAttrListDataApi}/${category1Id}/${category2Id}/${category3Id}`)
// 7.发送请求 删除 平台属性 数据
export const reqDelAttrInfo = (attrId: number) => request.delete<any,null>(`${Api.deleteAttrListApi}/${attrId}`)
// 8.发送请求 添加/修改 平台属性 数据
export const reqSaveAttrInfo = (attrInfo: attrInfoModel) => request.post<any, null>(Api.saveAttrInfoApi, attrInfo)